





<template>

  <div class="table-container">
    <div class="special-title">{{ currentDate }} A股跌停复盘</div>
    <div class="excel-container">
      <el-table :data="tableData" style="width:100%;margin-bottom: 20px;overflow-x: auto" row-key="id"
                default-expand-all
                :tree-props="{ children: 'children', hasChildren: 'hasChildren' }" class="custom-table">
        <el-table-column prop="continueDay" label="连板" sortable class="column-style">
        </el-table-column>

        <el-table-column prop="name" label="股票名称" sortable class="column-style">
        </el-table-column>

        <el-table-column prop="ticker" label="股票代码" sortable class="column-style">
        </el-table-column>

        <el-table-column prop="open" label="行业" sortable class="column-style">
          <template slot-scope="scope">
            {{ scope.row.industry}}
          </template>
        </el-table-column>

        <el-table-column prop="price" label="当前价格/元" sortable  class="column-style">
          <template slot-scope="scope">
            {{ scope.row.price ? parseFloat(scope.row.price)?.toFixed(2) : '' }}
          </template>
        </el-table-column>



        <!--        <el-table-column prop="high" label="最高价/元" sortable width="100" class="column-style">-->
        <!--        </el-table-column>-->

        <!--        <el-table-column prop="low" label="最低价/元" sortable width="100" class="column-style">-->
        <!--        </el-table-column>-->

        <!--        <el-table-column prop="pre_close" label="昨收价/元" sortable width="100" class="column-style">-->
        <!--        </el-table-column>-->

        <el-table-column prop="change" label="涨跌额 " sortable  class="column-style">
          <template slot-scope="scope">
            {{ scope.row.change ? parseFloat(scope.row.change)?.toFixed(2) : '' }}
          </template>
        </el-table-column>

        <!--        <el-table-column prop="pct_chg" label="涨跌幅" sortable width="100" class="column-style">-->
        <!--          <template slot-scope="scope">-->
        <!--            {{ scope.row.pct_chg ? parseFloat(scope.row.pct_chg)?.toFixed(2) : '' }}-->
        <!--          </template>-->
        <!--        </el-table-column>-->

        <el-table-column prop="vol" label="成交量/手" sortable class="column-style">
          <template slot-scope="scope">
            {{ scope.row.vol ? parseFloat(scope.row.vol)?.toFixed(0) : '' }}
          </template>
        </el-table-column>

        <el-table-column prop="amount" label="成交额" sortable class="column-style amount-column">
          <template slot-scope="scope">
            <span class="amount-value">
              {{ formatAmount(scope.row.amount) }}
              <span class="unit" v-if="formatAmount(scope.row.amount) !== ''"> 亿</span>
            </span>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <div style="height:1000px"></div>
  </div>
</template>

<script>
import axios from 'axios'

export default {
  data() {
    return {
      tableData: [],
      tableHeight: '80vh', // 设置高度为视窗高度的80%
      currentDate: ''
    }
  },
  methods: {
    formatAmount(amount) {
      if (amount === null || amount === undefined || amount === '') return '';
      return (parseFloat(amount) / 100000).toFixed(2);
    },
    profitList() {
      axios({
        method: 'get',
        url: '/api/stock/base/loss/list',
      })
          .then(res => {
            this.tableData = res.data.data
          })
    },

    getFormattedDate() {
      const today = new Date();
      const year = today.getFullYear();
      // JavaScript的月份是从0开始计算的，所以需要加1，并且判断是否小于10，前面加0
      const month = String(today.getMonth() + 1).padStart(2, '0');
      // 获取当日日期，并判断是否小于10，前面加0
      const day = String(today.getDate()).padStart(2, '0');

      // 格式化后的日期
      this.currentDate = `${year}年${month}月${day}日`;
    }
  },
  created() {
    this.profitList();
    this.getFormattedDate();


  }
}
</script>


<style scoped>


/* 增强红色系商务风格 */
.table-container {
  background: linear-gradient(135deg, #F0FFF4 0%, #9BE8A8 100%);
  padding: 1.4rem;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(198,40,40,0.1);
  font-family: '微软雅黑', '思源黑体', sans-serif;
}

/* 强化标题 */
.special-title {
  color: #2E7D32; /* 深绿色 */
  margin: 0 0 0.5rem;
  position: relative;
  padding-bottom: 0.4rem;
  font-size: 2.8rem !important;  /* 加大字号 */
  font-weight: 700;             /* 加粗 */
  letter-spacing: 0.12em;       /* 增加字间距 */
  text-shadow: 1px 1px 2px rgba(46,125,50,0.1); /* 添加文字阴影 */
  margin-bottom: 0.3rem !important;
}
.amount-value {
  font-family: 'Roboto Mono', monospace;
  /*font-weight: 600;*/
  /*color: #1a237e;*/
  position: relative;
  padding-right: 1em;
}

.unit {
  font-size: 0.85em;
  /*color: #444446;*/
  position: absolute;
  right: 0;
  bottom: 0em;
  line-height: 1;
  margin: 0 0;
  padding: 0 0;
}

/*.special-title::after {*/
/*  content: '';*/
/*  position: absolute;*/
/*  left: 50%;*/
/*  bottom: 0;*/
/*  transform: translateX(-50%);*/
/*  width: 120px;*/
/*  height: 3px;*/
/*  background: linear-gradient(90deg, #c62828 0%, #ef5350 100%);*/
/*}*/

/* 表头增强 */
::v-deep .custom-table th {
  background: linear-gradient(180deg, #4CAF50 0%, #388E3C 100%);
  color: #fff;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-right: 1px solid rgba(255,255,255,0.15);
}

/* 数据行优化 */
::v-deep .custom-table td {
  background: rgba(255,255,255,0.95);
  color: #1B5E20; /* 深墨绿色 */
  font-size: 1.4rem;
  border-bottom: 1px solid #ffebee;
  transition: all 0.25s ease;
}

/* 数字强化 */
::v-deep .el-table__cell .cell {
  font-family: 'Roboto Mono', monospace;
  font-weight: 500;
}
[prop="continueDay"] .cell {
  color: #388E3C;
  font-size: 1.4rem;
  font-weight: 700;
}
[prop="change"] .cell {
  color: #2E7D32;
  position: relative;
  padding-left: 1.2rem;
}
[prop="change"] .cell::before {
  content: '↑';
  position: absolute;
  left: 0;
  color: #4CAF50;
}

/* 交互优化 */
::v-deep .el-table__row {
&:hover td {
   background: #f0fff4 !important;
   transform: scale(1.005);
   box-shadow: 0 2px 8px rgba(76,175,80,0.08);
 }
}

/* 专业容器 */
.excel-container {
  margin: 0 5%;
  border: 2px solid #ffcdd2;
  border-radius: 10px;
  background: #fff;
  box-shadow: inset 0 0 12px rgba(255,205,210,0.15);
}

/* 状态标签 */
::v-deep .positive {
  background: #ffebee;
  padding: 0.2rem 0.8rem;
  border-radius: 4px;
  border-left: 3px solid #c62828;
}
</style>